/** 
 * Copyright(C) 2010-2011 <webPrj> LTD. All Rights Reserved.                               
 * Project: webPrj
 * Module ID: <0001>
 * Comments: TODO         
 * JDK version used: <JDK1.6.0_25>                              
 * Author: xiamingxing
 * Create Date：10:17:22
 * Modified By: xiamingxing                              
 * Modified Date: 10:17:22                                  
 * Why & What is modified: <修改原因描述>    
 * Version: V1.0                  
 */
package com.xiamx.platform.core.system.action;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.xiamx.platform.core.action.base.BaseAction;
import com.xiamx.platform.core.system.bo.IUserBo;
import com.xiamx.platform.exception.AppException;

public class LoginAction extends BaseAction {

	private static final long serialVersionUID = 5519615820343841261L;
	private static Logger logger = Logger.getLogger(LoginAction.class);
	
	private String userName;
	private String passWord;
	
	private IUserBo userBo;
	
	@Override
	public String executeAction() {
//		int flag = 0;
//		try {
//			Map<String,String> paraMap = new HashMap<String,String>();
//			paraMap.put("userName", userName);
//			paraMap.put("passWord", passWord);
//			flag = userBo.checkUser(paraMap);
//		} catch (AppException e) {
//			flag = 0;
//			logger.error(e);
//		} catch (SQLException e) {
//			flag = 0;
//			logger.error(e);
//		} catch (Exception e) {
//			flag = 0;
//			logger.error(e);
//		}
//		if(1 == flag) {
//			return SUCCESS;
//		} else {
//			return ERROR;
//		}
		return SUCCESS;
	}
	
	public String login() {
		int flag = 0;
		try {
			Map<String,String> paraMap = new HashMap<String,String>();
			paraMap.put("userName", userName);
			paraMap.put("passWord", passWord);
			flag = userBo.checkUser(paraMap);
		} catch (AppException e) {
			flag = 0;
			logger.error(e);
		} catch (SQLException e) {
			flag = 0;
			logger.error(e);
		} catch (Exception e) {
			flag = 0;
			logger.error(e);
		}
		if(1 == flag) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassWord() {
		return passWord;
	}

	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}

	public IUserBo getUserBo() {
		return userBo;
	}

	public void setUserBo(IUserBo userBo) {
		this.userBo = userBo;
	}

}

